package io.wdb.common.xss;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;

/**
 * XSS过滤
 * @author wdb
 * @email admin@wdb007.com
 * @date 2017-04-01 10:20
 */
public class XssFilter implements Filter {
	private Logger logger = LoggerFactory.getLogger(XssFilter.class);
	@Override
	public void init(FilterConfig config) throws ServletException {
	}

	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
            throws IOException, ServletException {
		HttpServletRequest httpServletRequest = (HttpServletRequest) request;
		String token = httpServletRequest.getParameter("token");
		logger.info("用户上传的token数据为:token"+token);
		XssHttpServletRequestWrapper xssRequest = new XssHttpServletRequestWrapper(
				(HttpServletRequest) request);
		chain.doFilter(xssRequest, response);
	}

	@Override
	public void destroy() {
	}

}